<template>
	<view class="flex-row">
		<img :src="url" :style="{'width': width,'height': height}" mode="aspectFit" alt="">
		<span class="font-12" :style="{'color': 'var(--tai-tips-color)'}">{{ number }}%</span>
	</view>
</template>

<script>
	import battery100 from '../../static/icons/svg/battery-100.svg'
	import battery80 from '../../static/icons/svg/battery-80.svg'
	import battery60 from '../../static/icons/svg/battery-60.svg'
	import battery40 from '../../static/icons/svg/battery-40.svg'
	import battery20 from '../../static/icons/svg/battery-20.svg'
	export default {

		name: 'BatteryIcon',
		props: {
			width: {
				type: String,
				default: '36rpx'
			},
			height: {
				type: String,
				default: '36rpx'
			},
			number: {
				type: Number
			}
		},
		data() {
			return {
				battery100
			}
		},
		computed: {
			url() {
				console.log(this.number);
				if (this.number <= 100 && this.number >= 80 ) {
					return battery100
				} else if (this.number < 80 && this.number >= 60) {
					return battery80
				}else if (this.number < 60 && this.number >= 40) {
					return battery60
				}else if (this.number < 40 && this.number >= 20) {
					return battery40
				}else if (this.number < 20 && this.number >= 0) {
					return battery20
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.flex-row {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
</style>
